package com.vsc.print_service.util;

import org.springframework.validation.ObjectError;

import java.util.List;

public class ResultObject<T> {
	private int code;
	private String message;
	private List<ObjectError> parameterErrors;
	T data;

	public ResultObject(com.vsc.print_service.util.MessageCode code) {
		this.code = code.getCode();
		this.message = com.vsc.print_service.util.MessageUtils.getMessage(code.name());
	}

	public ResultObject(com.vsc.print_service.util.MessageCode code, T data, String...argv) {
		this.code = code.getCode();
		this.message = com.vsc.print_service.util.MessageUtils.getMessage(code.name(), argv);
		this.data = data;
	}
	
	public ResultObject(com.vsc.print_service.util.MessageCode code, T data, List<ObjectError> parameterErrors) {
		this.code = code.getCode();
		this.message = com.vsc.print_service.util.MessageUtils.getMessage(code.name());
		this.data = data;
		this.parameterErrors = parameterErrors;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public List<ObjectError> getParameterErrors() {
		return parameterErrors;
	}
	public void setParameterErrors(List<ObjectError> parameterErrors) {
		this.parameterErrors = parameterErrors;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
}
